package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type ViperDataStruct struct {
	Mysql struct {
		User     string
		Password string
		Host     string
		Port     int
		Database string
	}
	Redis struct {
		Addr     string
		Password string
		DB       int
	}
	SendSms struct {
		AccessKeyId     string
		AccessKeySecret string
	}
	Jwt struct {
		Key string
	}
	Upload struct {
		AccessKey string
		SecretKey string
		Bucket    string
		Url       string
	}
}

var Data ViperDataStruct

func ViperDataFs() {
	viper.SetConfigFile("../appconfig/config.yaml")

	err := viper.ReadInConfig()
	if err != nil {
		panic(err)
	} else {
		fmt.Println("文件读取成功")
	}

	err = viper.Unmarshal(&Data)
	if err != nil {
		panic(err)
	} else {
		fmt.Println("文件转json成功")
	}
	fmt.Println(Data)

}
